<?php
/**
 *  Create On 2015-01-03
 *  Author Yiwei
 *  QQ:1006629314
 **/
class modify{
	protected $_data;
	
	private $sub_projection = array(
		'1'=>1,
		'23'=>2,
		'24'=>3
	);
	
	private $type_projection = array(
		
	);
	
	public function __construct($data){
		$this->_data = $data;
		
	}
	
	public function doModify(){

		//$type_id = &$this->_data['type_id'];
		//echo $this->_data['sub_id'];
		//echo '->'.$this->sub_projection[$this->_data['sub_id']].'<br>->';
		$this->_data['sub_id'] = $this->sub_projection[$this->_data['sub_id']];
		//echo $this->_data['sub_id'];
		//$type_id = $this->type_projection[$type_id];
		
		$json = json_decode($this->_data['json'],true);
		
		//$head = $json['head'];
		$nodeTree = &$json['nodeTree'];
		$this->modifyNode(&$nodeTree);
		
		$this->_data['json'] = json_encode($json);
		return $this->_data;
	}
	
	private function modifyNode($node){
		//echo "---------------------------------<br>";
		//var_dump($node['knows']);
		if($node['knows']){
			foreach ($node['knows'] as $kkey=>$knows){
				if($knows['name'] == '公式图片'){
					unset($node['knows'][$kkey]);
				}
			}
		}
		//var_dump($node['knows']);
		
		$children = $node['children'];
		for($k = 0; $k <count($children); $k++){
			$this->modifyNode($children[$k]);
		}
		
		
	}
	

	
}